#ifndef EVENTLOOP_PPOLLER_H
#define EVNETLOOP_PPOLLER_H

#include "Poller.h"
#include "utility/chrono.h"

#include <map>
#include <vector>

struct pollfd;

class PPoller : public Poller
{
public:
    using PollfdList = std::vector<pollfd>;
    using ChannelMap = std::map<int, Channel *>;    // <fd, Channel *>

    PPoller(Eventloop *loop);
    virtual ~PPoller();

    virtual Utility::timepoint poll(int timeout, ChannelList *activeChannels);
    virtual void update_channel(Channel *channel) override;
    virtual void remove_channel(Channel *channel) override;

private:
    void _fillActiveChannels(int numEvents, ChannelList *activeChannels) const;
    
    PollfdList _pollfds;
    ChannelMap _channels;
};



#endif